//
//  Tools.m
//  PiPiPineapple
//
//  Created by 李晓东 on 17/10/29.
//  Copyright © 2017年 PeanutXu. All rights reserved.
//

#import "Tools.h"
#import "DoubleChromosphere_Extension.h"
@implementation Tools

+ (instancetype)shareTools{
    static id tools = nil;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        tools = [[Tools alloc]init];
    });
    return tools;
}

- (NSArray *)splitAll:(NSArray *)originArray{
    NSMutableArray *splitArray = [NSMutableArray arrayWithCapacity:14];

    for (NSString *tempStr in originArray) {
        for (int i = 0; i < tempStr.length; i++) {
            
            [splitArray addObject:[NSString stringWithFormat:@"%C", [tempStr characterAtIndex:i]]];
        }
        
    }
    return splitArray;
}

- (int)countSplitAll:(NSArray *)calculateArray{
    int i = 0;
    for (NSString *tempStr in calculateArray) {
         i += [tempStr intValue];
    }
    while (i > 33) {
        i -= 33;
    }
    return i;
}

// MARK: 检查值是否大于33
- (NSInteger)checkIfMoreThan33:(NSInteger)originValue{
    while (originValue > 33) {
        originValue = originValue - 33;
    }
    return originValue;
}

- (NSInteger)checkIfLargeThan33:(NSInteger)num{
    NSInteger multiple = num / 33;
    return num > 33 ? num - multiple * 33 : num;
}

- (NSArray *)type1:(NSArray *)originArray{
    for (DoubleChromosphere *obj in originArray) {
        NSInteger someBody = 0;
        NSArray *redBalls = obj.returnRedBall;
        for (NSString *redBall in redBalls) {
            someBody += [[NSString stringWithFormat:@"%C", [redBall characterAtIndex:0]] integerValue] + [[NSString stringWithFormat:@"%C", [redBall characterAtIndex:1]] integerValue];
        }
        [obj setSomebody:[NSString stringWithFormat:@"%ld", [self checkIfLargeThan33:someBody]]];
    }
    return originArray;
}

- (NSArray *)countACValue:(NSArray *)originArray{
    NSArray *calculateArray = nil;
    calculateArray = [Tools countACValue:originArray];
    return calculateArray;
    
}

+ (NSArray *)countACValue:(NSArray *)originArray{
    NSMutableArray *calculateArray = [NSMutableArray array];
    // 循环每一个 DoubleChromosphere
    for (int k = 0; k < originArray.count; k++) {
        DoubleChromosphere *obj = (DoubleChromosphere *)originArray[k];
        
        NSMutableArray *mutableArray = [NSMutableArray array];
        for (int i = 0; i < obj.returnRedBall.count; i++) {
            for (int j = i; j < obj.returnRedBall.count; j++) {
                NSInteger afterNum = [NSString stringWithFormat:@"%@", obj.returnRedBall[j]].integerValue;
                NSInteger beforeNum = [NSString stringWithFormat:@"%@", obj.returnRedBall[i]].integerValue;
                
                NSInteger value = afterNum - beforeNum;
                if (![mutableArray containsObject:[NSString stringWithFormat:@"%ld", value]] && value != 0) {
                    [mutableArray addObject:[NSString stringWithFormat:@"%ld", (long)value]];
                }
                
            }
            
        }
        NSInteger result = mutableArray.count - (6 - 1);
        NSString *formatterStr = result > 9 ? @"%ld" : @"0%ld" ;
        [obj setAcValue:[NSString stringWithFormat:formatterStr, result]];
        [calculateArray addObject:obj];
    }
    
    return calculateArray;
}

- (NSArray *)type4:(NSArray *)originArray{
    [self countACValue:originArray];
    for (DoubleChromosphere *tempObj in originArray) {
        [tempObj setSomebody:[NSString stringWithFormat:@"%02ld", [tempObj.returnBlueBall integerValue] + [tempObj.returnACValue integerValue]]];
    }
    return originArray;
}

//MARK: 红球尾数之和杀号
- (NSArray *)type5:(NSArray *)originArray{
    for (int i = 0; i < originArray.count; i++) {
        DoubleChromosphere *obj = (DoubleChromosphere *)originArray[i];
        NSArray *splitArray = [self splitAll:obj.returnRedBall];
        NSInteger sum = 0;
        for (int i = 1; i < 12; i+=2) {
            sum += [splitArray[i] integerValue];
        }
        [obj setSomebody:[NSString stringWithFormat:@"%02ld", sum]];
        NSLog(@"")  ;
    }
    return originArray;
}

- (NSArray *)methodStation:(NSArray *)originArray andMethodNum:(NSInteger)num{
    switch (num) {
        case 1:
            originArray = [self method2:originArray];
            break;
        case 2:
            originArray = [self method3:originArray];
            break;
        case 3:
            originArray = [self method4:originArray];
            break;
        case 4:
            originArray = [self method5:originArray];
            break;
        case 5:
            originArray = [self method6:originArray];
            break;
        case 6:
            originArray = [self method7:originArray];
            break;
        case 7:
            originArray = [self method8:originArray];
            break;
        case 8:
            originArray = [self method9:originArray];
            break;
        case 9:
            originArray = [self method10:originArray];
            break;
        case 10:
            originArray = [self method11:originArray];
            break;
        case 11:
            originArray = [self method12:originArray];
            break;
        case 12:
            originArray = [self method13:originArray];
            break;
        case 13:
            originArray = [self method14:originArray];
            break;
        case 14:
            originArray = [self method15:originArray];
            break;
        case 15:
            originArray = [self method16:originArray];
            break;
        case 16:
            originArray = [self method17:originArray];
            break;
        case 17:
            originArray = [self method18:originArray];
            break;
        default:
            break;
    }
    return originArray;
}

// MARK: 降龙十八掌 系列
- (NSArray *)method2:(NSArray *)originArray{
    for (int k = 0; k < originArray.count; k++) {
        DoubleChromosphere *obj = (DoubleChromosphere *)originArray[k];
        NSInteger tempInteger = [self checkIfMoreThan33:[obj.returnRedBall[0] integerValue]  + [obj.returnRedBall[1] integerValue]];
        obj.somebody = [NSString stringWithFormat:@"%02ld", tempInteger];
    }
    return originArray;
}

- (NSArray *)method3:(NSArray *)originArray{
    for (int k = 0; k < originArray.count; k++) {
        DoubleChromosphere *obj = (DoubleChromosphere *)originArray[k];
        NSInteger tempInteger = [self checkIfMoreThan33:[obj.returnRedBall[1] integerValue]  - [obj.returnRedBall[0] integerValue]];
        obj.somebody = [NSString stringWithFormat:@"%02ld", tempInteger];
    }
    return originArray;
}

- (NSArray *)method4:(NSArray *)originArray{
    for (int k = 0; k < originArray.count; k++) {
        DoubleChromosphere *obj = (DoubleChromosphere *)originArray[k];
        NSInteger tempInteger = [self checkIfMoreThan33:[obj.returnRedBall[3] integerValue]  + [obj.returnRedBall[0] integerValue]];
        obj.somebody = [NSString stringWithFormat:@"%02ld", tempInteger];
    }
    return originArray;
}

- (NSArray *)method5:(NSArray *)originArray{
    for (int k = 0; k < originArray.count; k++) {
        DoubleChromosphere *obj = (DoubleChromosphere *)originArray[k];
        NSInteger tempInteger = [self checkIfMoreThan33:[obj.returnRedBall[4] integerValue]  - [obj.returnRedBall[2] integerValue]];
        obj.somebody = [NSString stringWithFormat:@"%02ld", tempInteger];
    }
    return originArray;
}

- (NSArray *)method6:(NSArray *)originArray{
    for (int k = 0; k < originArray.count; k++) {
        DoubleChromosphere *obj = (DoubleChromosphere *)originArray[k];
        NSInteger tempInteger = [self checkIfMoreThan33:[obj.returnRedBall[5] integerValue]  - [obj.returnRedBall[1] integerValue] + 1];
        obj.somebody = [NSString stringWithFormat:@"%02ld", tempInteger];
    }
    return originArray;
}

- (NSArray *)method7:(NSArray *)originArray{
    for (int k = 0; k < originArray.count; k++) {
        DoubleChromosphere *obj = (DoubleChromosphere *)originArray[k];
        NSInteger tempInteger = [self checkIfMoreThan33:[obj.returnRedBall[5] integerValue]  - [obj.returnRedBall[1] integerValue] + 10];
        obj.somebody = [NSString stringWithFormat:@"%02ld", tempInteger];
    }
    return originArray;
}

- (NSArray *)method8:(NSArray *)originArray{
    for (int k = 0; k < originArray.count; k++) {
        DoubleChromosphere *obj = (DoubleChromosphere *)originArray[k];
        NSInteger tempInteger = [self checkIfMoreThan33:[obj.returnRedBall[3] integerValue]  - [obj.returnRedBall[0] integerValue] + 7];
        obj.somebody = [NSString stringWithFormat:@"%02ld", tempInteger];
    }
    return originArray;
}

- (NSArray *)method9:(NSArray *)originArray{
    for (int k = 0; k < originArray.count; k++) {
        DoubleChromosphere *obj = (DoubleChromosphere *)originArray[k];
        NSInteger tempInteger = [self checkIfMoreThan33:[obj.returnRedBall[0] integerValue] + 12];
        obj.somebody = [NSString stringWithFormat:@"%02ld", tempInteger];
    }
    return originArray;
}

- (NSArray *)method10:(NSArray *)originArray{
    for (int k = 0; k < originArray.count; k++) {
        DoubleChromosphere *obj = (DoubleChromosphere *)originArray[k];
        NSInteger tempInteger = [self checkIfMoreThan33: [obj.returnRedBall[5] integerValue]  - [obj.returnRedBall[0] integerValue]];
        obj.somebody = [NSString stringWithFormat:@"%02ld", tempInteger];
    }
    return originArray;
}

- (NSArray *)method11:(NSArray *)originArray{
    for (int k = 0; k < originArray.count; k++) {
        DoubleChromosphere *obj = (DoubleChromosphere *)originArray[k];
        NSInteger tempInteger = [self checkIfMoreThan33:[obj.returnRedBall[5] integerValue] + [obj.returnBall.lastObject integerValue]];
        obj.somebody = [NSString stringWithFormat:@"%02ld", tempInteger];
    }
    return originArray;
}

- (NSArray *)method12:(NSArray *)originArray{
    for (int k = 0; k < originArray.count; k++) {
        DoubleChromosphere *obj = (DoubleChromosphere *)originArray[k];
        NSInteger tempInteger = [self checkIfMoreThan33:([obj.returnRedBall[0] integerValue]  + [obj.returnRedBall[1] integerValue] + [obj.returnRedBall[2] integerValue]) / 3];
        obj.somebody = [NSString stringWithFormat:@"%02ld", tempInteger];
    }
    return originArray;
}

- (NSArray *)method13:(NSArray *)originArray{
    for (int k = 0; k < originArray.count; k++) {
        DoubleChromosphere *obj = (DoubleChromosphere *)originArray[k];
        NSInteger tempInteger = [self checkIfMoreThan33:([obj.returnRedBall[1] integerValue]  + [obj.returnRedBall[2] integerValue] + [obj.returnRedBall[3] integerValue] + [obj.returnRedBall[4] integerValue] + [obj.returnBall.lastObject integerValue]) / 6];
        obj.somebody = [NSString stringWithFormat:@"%02ld", tempInteger];
    }
    return originArray;
}
- (NSArray *)method14:(NSArray *)originArray{
    for (int k = 0; k < originArray.count; k++) {
        DoubleChromosphere *obj = (DoubleChromosphere *)originArray[k];
        NSInteger tempInteger = [self checkIfMoreThan33:([obj.returnRedBall[2] integerValue] + [obj.returnRedBall[3] integerValue] + [obj.returnRedBall[4] integerValue] + [obj.returnRedBall[5] integerValue]) / 4 ];
        obj.somebody = [NSString stringWithFormat:@"%02ld", tempInteger];
    }
    return originArray;
}

- (NSArray *)method15:(NSArray *)originArray{
    for (int k = 0; k < originArray.count; k++) {
        DoubleChromosphere *obj = (DoubleChromosphere *)originArray[k];
        NSInteger tempInteger = [self checkIfMoreThan33:[obj.returnRedBall[1] integerValue] + [obj.returnBall.lastObject integerValue]];
        obj.somebody = [NSString stringWithFormat:@"%02ld", tempInteger];
    }
    return originArray;
}

- (NSArray *)method16:(NSArray *)originArray{
    for (int k = 0; k < originArray.count; k++) {
        DoubleChromosphere *obj = (DoubleChromosphere *)originArray[k];
        NSInteger tempInteger = [self checkIfMoreThan33:[obj.returnRedBall[1] integerValue] + [obj.returnRedBall[2] integerValue]];
        obj.somebody = [NSString stringWithFormat:@"%02ld", tempInteger];
    }
    return originArray;
}

- (NSArray *)method17:(NSArray *)originArray{
    for (int k = 0; k < originArray.count; k++) {
        DoubleChromosphere *obj = (DoubleChromosphere *)originArray[k];
        NSInteger tempInteger = [self checkIfMoreThan33:[obj.returnRedBall[4] integerValue]  - [obj.returnRedBall[3] integerValue] + 10];
        obj.somebody = [NSString stringWithFormat:@"%02ld", tempInteger];
    }
    return originArray;
}

- (NSArray *)method18:(NSArray *)originArray{
    for (int k = 0; k < originArray.count; k++) {
        DoubleChromosphere *obj = (DoubleChromosphere *)originArray[k];
        NSInteger tempInteger = [self checkIfMoreThan33:[obj.returnRedBall[1] integerValue] + [obj.returnRedBall[5] integerValue] + 1];
        obj.somebody = [NSString stringWithFormat:@"%02ld", tempInteger];
    }
    return originArray;
}

/// TODO:将上期和上上期号码相加,得数大于33,则减去33
- (NSArray *)type7:(NSArray *)originArray{
    for (int k = originArray.count; k > 2; k--) {
        DoubleChromosphere *frontOf2 = (DoubleChromosphere *)originArray[k - 2];
        DoubleChromosphere *frontOf1 = (DoubleChromosphere *)originArray[k - 1];
        
        NSArray<NSString *> *frontOf2RedBalls = frontOf2.returnRedBall;
        NSArray<NSString *> *frontOf1RedBalls = frontOf1.returnRedBall;
        
        NSMutableString *mutableString = [NSMutableString string];
        for (int i = 0; i < frontOf2RedBalls.count; i++) {
            [mutableString appendString:[NSString stringWithFormat:@"%02ld ", [self checkIfLargeThan33:[frontOf2RedBalls[i] integerValue] + [frontOf1RedBalls[i] integerValue]]]];
        }
        DoubleChromosphere *doubleChromosphere = (DoubleChromosphere *)originArray[k - 3];
        [doubleChromosphere setNextSomeBody:mutableString];
    }
    
    originArray = [originArray subarrayWithRange:NSMakeRange(0, originArray.count - 2)];
    return originArray;
}

- (NSArray *)type8:(NSArray *)originArray{
//    NSMutableArray *calculateArray = [NSMutableArray array];
    for (int k = originArray.count; k > 1; k--) {
        DoubleChromosphere *obj = (DoubleChromosphere *)originArray[k - 1];
        NSArray *redBall = obj.returnRedBall;
        NSMutableArray *issueArray = [NSMutableArray array];
        for (NSString *tempStr in redBall) {
            [issueArray addObject:[NSString stringWithFormat:@"%ld", ABS([tempStr integerValue] - 17)]];
        }// 还没决定是否要排序
        
//        [calculateArray addObject:issueArray];
        DoubleChromosphere *preObj = (DoubleChromosphere *)originArray[k - 2];
        [preObj setNextSomeBody:issueArray];
    }
    originArray = [originArray subarrayWithRange:NSMakeRange(0, originArray.count - 1)];
    return originArray;
}

- (NSArray *)type9:(NSArray *)originArray{
    for (int k = originArray.count; k > 2; k--) {
        DoubleChromosphere *frontOf2 = (DoubleChromosphere *)originArray[k - 2];
        DoubleChromosphere *frontOf1 = (DoubleChromosphere *)originArray[k - 1];
        
        NSString *frontOf2BlueBall = frontOf2.returnBlueBall;
        NSArray<NSString *> *frontOf1RedBalls = frontOf1.returnRedBall;
        
        NSMutableString *mutableString = [NSMutableString string];
        for (int i = 0; i < frontOf1RedBalls.count; i++) {
            [mutableString appendString:[NSString stringWithFormat:@"%02ld ", [self checkIfLargeThan33:[frontOf2BlueBall integerValue] + [frontOf1RedBalls[i] integerValue]]]];
        }
        DoubleChromosphere *doubleChromosphere = (DoubleChromosphere *)originArray[k - 3];
        [doubleChromosphere setNextSomeBody:mutableString];
    }
    
    originArray = [originArray subarrayWithRange:NSMakeRange(0, originArray.count - 2)];
    return originArray;
}

- (NSArray *)type10:(NSArray *)originArray{
//    NSMutableArray *calculateArray = [NSMutableArray array];
    for (int k = 0; k < originArray.count; k++) {
        DoubleChromosphere *obj = (DoubleChromosphere *)originArray[k];
        NSArray *redBall = obj.returnRedBall;
        NSMutableArray *resultsNum = [NSMutableArray arrayWithArray:redBall];

        for (int j = 0; j < 5; j++) {
            NSInteger count = resultsNum.count;
            NSMutableArray *tempArray = [NSMutableArray array];
            for (int i = 0; i < count - 1; i++) {
                [tempArray addObject:[NSString stringWithFormat:@"%ld", [resultsNum[i + 1] integerValue] - [resultsNum[0] integerValue]]];
            }
            [resultsNum replaceObjectsInRange:NSMakeRange(0, resultsNum.count) withObjectsFromArray:tempArray];

        }
        [obj setSomebody:resultsNum.lastObject];
//        [calculateArray addObject:resultsNum.lastObject];
    }
    return originArray;
}

- (NSArray *)type11:(NSArray *)originArray{
    NSMutableArray *calculateArray = [NSMutableArray array];
    for (int k = originArray.count; k > 2; k--) {
        NSMutableArray *issueArray = [NSMutableArray array];
        DoubleChromosphere *frontOf1 = (DoubleChromosphere *)originArray[k - 1];
        DoubleChromosphere *frontOf2 = (DoubleChromosphere *)originArray[k - 2];
        NSArray *plusArray = frontOf2.returnRedBall;
        NSArray *array = frontOf1.returnRedBall;
        for (int i = 0; i < plusArray.count; i++) {
           [issueArray addObject:[NSString stringWithFormat:@"%ld", ABS([array[i] integerValue] - [plusArray[0] integerValue])]];
        }
        DoubleChromosphere *doubleChromosphere = (DoubleChromosphere *)originArray[k - 3];
        [doubleChromosphere setNextSomeBody:issueArray];

    }
    originArray = [originArray subarrayWithRange:NSMakeRange(0, originArray.count - 2)];
    return originArray;
}

- (NSArray *)type12:(NSArray *)originArray{
    NSMutableArray *calculateArray = [NSMutableArray array];
    for (DoubleChromosphere *obj in originArray) {
        NSArray *redArray = obj.returnRedBall;
        NSString *min, *max;
        Boolean minFlag = NO , maxFlag = NO;
        for (int i = 0; i < redArray.count; i++) {
            if ([(NSString *)redArray[i] integerValue] % 2 != 0 && !minFlag) {
                min = redArray[i];
                minFlag = YES;
            }
            
            if ([(NSString *)redArray[redArray.count - i - 1] integerValue] %2 != 0 && !maxFlag) {
                max = redArray[redArray.count - i - 1];
                maxFlag = YES;
            }
            
        }
        NSInteger value = ([max integerValue] - [min integerValue]) / 2;
        [obj setSomebody:[NSString stringWithFormat:@"%02ld", value]];
    }
    return originArray;
}

- (NSArray *)type13:(NSArray *)originArray{
    NSMutableArray *calculateArray = [NSMutableArray array];
    for (DoubleChromosphere *obj in originArray) {
        NSArray *redArray = obj.returnRedBall;
        NSString *min, *max;
        Boolean minFlag = NO , maxFlag = NO;
        for (int i = 0; i < redArray.count; i++) {
            if ([(NSString *)redArray[i] integerValue] % 2 != 0 && !minFlag) {
                min = redArray[i];
                minFlag = YES;
            }
            
            if ([(NSString *)redArray[redArray.count - i - 1] integerValue] %2 != 0 && !maxFlag) {
                max = redArray[redArray.count - i - 1];
                maxFlag = YES;
            }
            
        }
        NSInteger value = ([max integerValue] + [min integerValue]) / 2;
        [obj setSomebody:[NSString stringWithFormat:@"%02ld", value]];
    }
    return originArray;
}

- (NSArray *)type14:(NSArray *)originArray{
    for (int k = originArray.count; k > 2; k--) {
        DoubleChromosphere *frontOf2 = (DoubleChromosphere *)originArray[k - 2];
        DoubleChromosphere *frontOf1 = (DoubleChromosphere *)originArray[k - 1];
        
        NSString *frontOf2BlueBall = frontOf2.returnBlueBall;
        NSString *frontOf1BlueBall = frontOf1.returnBlueBall;
        
        NSMutableString *mutableString = [NSMutableString string];
        
        [mutableString appendString:[NSString stringWithFormat:@"%02ld, ", [frontOf2BlueBall integerValue] + [frontOf1BlueBall integerValue]]];
        [mutableString appendString:[NSString stringWithFormat:@"%02ld", ABS([frontOf2BlueBall integerValue] - [frontOf1BlueBall integerValue])]];
        

        DoubleChromosphere *doubleChromosphere = (DoubleChromosphere *)originArray[k - 3];
        [doubleChromosphere setNextSomeBody:mutableString];
    }
    
    originArray = [originArray subarrayWithRange:NSMakeRange(0, originArray.count - 2)];
    return originArray;
}

/// 从type15到 type20算法一样,只是操作的位数不同
- (void)type15To20:(NSArray *)originArray useRed:(NSInteger)redBall toPlus:(NSInteger)method{
    for (int k = 0; k < originArray.count; k++) {
        DoubleChromosphere *obj = (DoubleChromosphere *)originArray[k];
        [obj setSomebody: [NSString stringWithFormat:@"%ld", [[obj returnRedBall][redBall] integerValue] + method]];
    }
}

- (NSArray *)type15:(NSArray *)originArray{
    [self type15To20:originArray useRed:0 toPlus:9];
    return originArray;
}

- (NSArray *)type16:(NSArray *)originArray{
    [self type15To20:originArray useRed:0 toPlus:2];
    return originArray;
}

- (NSArray *)type17:(NSArray *)originArray{
    [self type15To20:originArray useRed:1 toPlus:5];
    return originArray;
}

- (NSArray *)type18:(NSArray *)originArray{
    [self type15To20:originArray useRed:2 toPlus:7];
    return originArray;
}

- (NSArray *)type19:(NSArray *)originArray{
    [self type15To20:originArray useRed:2 toPlus:4];
    return originArray;
}

- (NSArray *)type20:(NSArray *)originArray{
    [self type15To20:originArray useRed:5 toPlus:4];
    return originArray;
}

//
- (NSArray *)type21:(NSArray *)originArray{
    for (int k = 0; k < originArray.count; k++) {
        DoubleChromosphere *obj = (DoubleChromosphere *)originArray[k];
        [obj setSomebody:[NSString stringWithFormat:@"%ld", [obj.returnRedBall[0] integerValue] * 4 - 2]];
        
    }
    return originArray;
}

- (NSArray *)type22:(NSArray *)originArray{
    for (int k = 0; k < originArray.count; k++) {
        DoubleChromosphere *obj = (DoubleChromosphere *)originArray[k];
        [obj setSomebody:[NSString stringWithFormat:@"%ld", [obj.returnRedBall[0] integerValue] + [obj.returnBlueBall integerValue]]];
        
    }
    return originArray;
}

- (NSArray *)type23:(NSArray *)originArray{
    for (int k = 0; k < originArray.count; k++) {
        DoubleChromosphere *obj = (DoubleChromosphere *)originArray[k];
        NSArray *redBalls = obj.returnRedBall;
        [obj setSomebody:[NSString stringWithFormat:@"%ld", [obj.returnBlueBall integerValue] + [redBalls[1] integerValue] - 1]];

    }
    return originArray;
}

- (NSArray *)type24:(NSArray *)originArray{
    for (int k = 0; k < originArray.count; k++) {
        DoubleChromosphere *obj = (DoubleChromosphere *)originArray[k];
        NSArray *redBalls = obj.returnRedBall;
        [obj setSomebody:[NSString stringWithFormat:@"%ld", [self checkIfLargeThan33:[obj.returnBlueBall integerValue] * [redBalls[0] integerValue]]]];
        
    }
    return originArray;
}

- (NSArray *)type25:(NSArray *)originArray{
    [self type25To27:originArray multiply:1 andAdd:7];
    return originArray;
}

- (NSArray *)type26:(NSArray *)originArray{
    [self type25To27:originArray multiply:1 andAdd:9];
    return originArray;
}

- (NSArray *)type27:(NSArray *)originArray{
    [self type25To27:originArray multiply:5 andAdd:2];
    return originArray;
}

// MARK: 从25到27之间的方法抽取
- (void)type25To27:(NSArray *)originArray multiply:(NSInteger)multiply andAdd:(NSInteger)add{
    for (int k = 0; k < originArray.count; k++) {
        DoubleChromosphere *obj = (DoubleChromosphere *)originArray[k];
        NSArray *redBalls = obj.returnRedBall;
        [obj setSomebody:[NSString stringWithFormat:@"%ld", [self checkIfMoreThan33:[obj.returnBlueBall integerValue] * multiply + add]]];
        
    }
}

- (NSArray *)type28:(NSArray *)originArray{
    for (int k = 0; k < originArray.count; k++) {
        NSMutableArray *issueArray = [NSMutableArray array];
        DoubleChromosphere *obj = (DoubleChromosphere *)originArray[k];
        [obj setSomebody:[NSString stringWithFormat:@"%ld", [obj.returnRedBall[5] integerValue] - [obj.returnBlueBall integerValue]]];
        
    }
    return originArray;
}


- (NSArray *)type29:(NSArray *)originArray{
    for (int k = 0; k < originArray.count; k++) {
        NSMutableArray *issueArray = [NSMutableArray array];
        DoubleChromosphere *obj = (DoubleChromosphere *)originArray[k];
        NSString *num = [NSString stringWithFormat:@"%ld", [obj.returnRedBall[5] integerValue] - [obj.returnBlueBall integerValue]];
        
        NSInteger numToInteger = [num integerValue] < 10 ? [num integerValue] : [[NSString stringWithFormat:@"%C", [num characterAtIndex:0]] integerValue] + [[NSString stringWithFormat:@"%C", [num characterAtIndex:1]] integerValue];
        
        
        NSString *result = [self checkInTableOfComparisons:[NSString stringWithFormat:@"%ld", numToInteger]];
        [obj setSomebody:result];
        
    }
    return originArray;
}

// type30实现不了,因为没有接口提供开球顺序的信息
- (NSArray *)type30:(NSArray *)originArray{
    
    return nil;
}

- (NSArray *)type32:(NSArray *)originArray{
    for (int k = 0; k < originArray.count; k++) {
        NSMutableArray *issueArray = [NSMutableArray array];
        DoubleChromosphere *obj = (DoubleChromosphere *)originArray[k];
        NSString *num = [NSString stringWithFormat:@"%ld", 34 - [obj.returnRedBall[0] integerValue]];
        [obj setSomebody:num];
    }
    return originArray;
}

// MARK: 比较11对照码
- (NSString *)checkInTableOfComparisons:(NSString *)num{
    NSDictionary *dict = @{@"1":@"12,23", @"2":@"13,24", @"3":@"14,25", @"4":@"15,26", @"5":@"16,27", @"6":@"17,28", @"7":@"18,29", @"8":@"19,30", @"9":@"20,31", @"10":@"21,32", @"11":@"22,33"};
    NSString *result = [dict objectForKey:num];
    return result;
}



@end
